<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        //将异步变同步，先封装一个函数 return 返回一个异步操作Promise，Promise中写异步代码

        //封装
        async function fn() {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('1');
                }, 1000);
            })
        }

        //使用
        async function start() {
            let s = await fn();
            console.log(s);
            console.log(await fn());
            console.log(await fn());
            console.log(await fn());
        }
        start();
    </script>
</body>

</html>